
Version:=1.4.4
ModuleName:=iptables

Objcet:=$(ModuleName).tgz
ObjectDir:=$(ModuleName)-$(Version)
ObjcetSource:=$(ModuleName)-$(Version).tar.bz2

ModuleName2:=l7-protocols
Version2:=2009-05-28
Objcet2:=$(ModuleName2).tgz
ObjectDir2:=$(ModuleName2)-$(Version2)
ObjcetSource2:=$(ModuleName2)-$(Version2).tar.gz

PatchFileName:=iptables-1.4.4-for-kernel-2.6.28.9-layer7-2.22.patch

DependFiles:=

InstallDirTmp:=`pwd`/
InstallDir:=/$(InstallDirTmp)
InstallBin:=$(InstallDir)/bin
InstallBinTmp:=$(InstallDirTmp)/bin
InstallLib:=$(InstallDir)/lib
InstallLibTmp:=$(InstallDirTmp)/lib
InstallMan:=$(InstallDir)/man

KernelDir:=$(shell cd ../kernel/linux-2.6.28.9; pwd )

PatchCommand:=patch -p0 < $(PatchFileName) 
#&& chmod +x ./extensions/.layer7-test && cd ../ && patch -p0 < iptables-1.3.7.libipt_time.patch
Config:=BINDIR=$(InstallBin)/ LIBDIR=$(InstallLib) MANDIR=$(InstallMan) \
	KERNEL_DIR=$(KernelDir) #NO_SHARED_LIBS=1 #DO_MULTI=1
.PHONY: all clean dist_clean


all:$(Objcet) $(Objcet2)


$(Objcet):$(ObjcetSource) 	
	tar -xf $(ObjcetSource)
	cd ./$(ObjectDir) && ./configure 
	$(MAKE) -C ../kernel/
	$(PatchCommand)
	cd ./$(ObjectDir) && ./configure --disable-ipv6 --with-kernel=$(KernelDir)
	cd ./$(ObjectDir) && $(MAKE) 
	cd ./$(ObjectDir) && $(MAKE) install DESTDIR=`pwd`/
	mv $(ObjectDir)/usr usr && mkdir -p usr/local/bin/
	rm -rf  usr/local/share/man usr/local/include
	ln -s /usr/local/sbin/iptables usr/local/bin/iptables
	tar -czf $(Objcet) usr

$(Objcet2):$(ObjcetSource2)
	rm -rf etc && mkdir etc/l7-protocols -p
	tar -xf $(ObjcetSource2)
	cp -rf $(ObjectDir2)/* etc/l7-protocols
	tar -czvf $(Objcet2) etc

clean:
	rm -rf usr $(Objcet) etc $(Objcet2)

dist_clean:clean
	rm -rf $(ObjectDir) $(ObjcetSource)  $(ObjectDir2) $(ObjcetSource2) *.tar.gz
	
include ../Makefile.Res
